package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.BatchDete;
import com.indusfo.spc.service.BatchDeteService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author liub
 * @Date 2019/12/5 15:08
 * @Version 1.0
 */

@Controller
@RequestMapping("/service/batchDete")
public class BatchDeteController {

    @Autowired
    private BatchDeteService batchDeteService;

    /**
     * 查询
     */
    @RequestMapping(value = "/queryBatchDete")
    @ResponseBody
    public JSONObject queryBatchDete(BatchDete batchDete) {
        JSONObject json = batchDeteService.queryBatchDete(batchDete);
        return json;
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/insertBatchDete", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject insertBatchDete(BatchDete batchDete) {
        JSONObject json = batchDeteService.insertBatchDete(batchDete);
        return json;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/updateBatchDete", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject updateBatchDete(BatchDete batchDete) {
        JSONObject json = batchDeteService.updateBatchDete(batchDete);
        return json;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/deleteBatchDete", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject deleteBatchDete(@RequestParam("batchDeteIds") List<Integer> batchDeteIds, Integer dataState) {
        dataState = 2;
        JSONObject json = batchDeteService.deleteBatchDete(batchDeteIds, dataState);
        return json;
    }

    /**
     * 启停
     */
    @RequestMapping(value = "/definedBatchDete", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject definedBatchDete(@RequestParam("batchDeteIds") List<Integer> batchDeteIds, Integer dataState) {
        JSONObject json = batchDeteService.deleteBatchDete(batchDeteIds, dataState);
        return json;
    }
}
